# 常量：开始
# 常量：版权
__author__: str = "寒冬利刃"
__version__ = None
__copyright__: str = "Copyright © 2025 寒冬利刃."

# 常量：程序
program_name: str = "寒冬消息轰炸机-界面文件展示器"
program_name_in_English: str = "HDmsgbomber-ui_shower"

# 常量：依赖
import os
import sys
import jinja2
import webview

# 常量：路径
if getattr(sys, "frozen", False):
    base_dir: str = os.path.abspath(os.path.dirname(sys.executable))
elif __file__:
    base_dir: str = os.path.abspath(os.path.dirname(__file__))
os.chdir(base_dir)

# 常量：界面
loader: jinja2.FileSystemLoader = jinja2.FileSystemLoader(f"{base_dir}\\ui")
env: jinja2.Environment = jinja2.Environment(loader = loader)
env.globals["base_dir"] = base_dir
env.globals["static"] = f"{base_dir}\\static"
env.globals["author"] = __author__
env.globals["version"] = __version__
env.globals["copyright"] = __copyright__
env.globals["program_name"] = program_name
env.globals["program_name_in_English"] = program_name_in_English
# 常量：结束

# 程序：开始
# 程序：主函数：开始
def main() -> None:
    file: str = input("加载哪个界面文件？")
    html = env.get_template(file).render()
    with open(file, "w", encoding = "utf-8") as f:
        f.write(html)
    root: webview.Window = webview.create_window(
        title = "", 
        url = file,  
        frameless = True, 
        easy_drag = True
    )
    webview.start(debug=True)
# 程序：主函数：结束
# 程序：结束

# 运行：开始
if __name__ == "__main__":
    main()
# 运行：结束